#include <bits/stdc++.h>
using namespace std;


void solve()
{
    long long n, k;
    cin >> n >> k;
    if(k & 1)
    {
        cout << "No" << endl;
        return;
    }
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++) a[i] = i;
    int i = 1;
    while(k)
    {
        if(i == n)
        {
            cout << "No" << endl;
            return;
        }
        int t = min(k / 2, n - 1);
        k -= t * 2;
        swap(a[i], a[i + t]);
        n--;
        i++;
    }
    cout << "YES" << endl;
    for(int i = 1; i < a.size(); i++) cout << a[i] << ' ';
    cout << endl;
}

int main()
{
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}